//商户详情
var nowpage = 1
var id = sessionStorage.getItem('go_detail')
// sessionStorage.setItem('go_detail', '')
console.log(id)
$.ajax({
    url:initObj.url + '/api/user/selectUserAdministrators/' + id,
    type:'get',
    datatype:'json',
    beforeSend: function(request) {
        request.setRequestHeader("token", form.token);
    //    console.log(form.token)
    },
    success:function(res){
        console.log(res)
        contacts.value = res.data.contacts
        idCard.innerHTML = res.data.idCard
        mechanismCode.innerHTML = res.data.mechanismCode
        merchantNo.innerHTML = res.data.merchantNo
        realName.innerHTML = res.data.realName
        state.innerHTML = res.data.state
        if(res.data.state == '锁定'){
            state.style.color = '#f95959'
        }else if(res.data.state == '正常'){
            state.style.color = '#63c459'
        }else{
            state.style.color = '#e0d42e'
        }
        telephone.value = res.data.telephone
        userInformation.value = res.data.userInformation
        username.innerHTML = res.data.username
        daifuedu.value = res.data.substituteMoney
        zhuanzhangedu.value = res.data.bringForwardMoney
    }
})
function update_user_info(){
    if(userInformation.value&&contacts.value&&telephone.value){
        $.ajax({
        url:initObj.url + '/api/user/updateUserAdministrators/' + id + '/' + userInformation.value + '/' + contacts.value + '/' + telephone.value + '/' + state.innerHTML + '/' + daifuedu.value + '/' + zhuanzhangedu.value,
        type:'put',
        contentType:'application/json;charset=utf-8',
        datatype:'json',
        beforeSend: function(request) {
            request.setRequestHeader("token", form.token);
        //    console.log(form.token)
        },
        success:function(res){
            console.log(res)
            alert(res.msg)
        }
        })
    }else{
        alert('不可为空')
    }
}
function update_state(){
    if(state.innerHTML == '正常'){
        state.innerHTML = '锁定'
        state.style.color = '#f95959'
        update_user_info()
        return 
    }
    if(state.innerHTML == '锁定'){
        state.innerHTML = '正常'
        state.style.color = '#63c459'
        update_user_info()
    }
}
// function shanghuxiangqin(){
//     document.getElementById('shanghupeizhi').style.display = "none"
//     document.getElementById('shanghuxiangqin').style.display = "block"
//     xiangqin.style.fontWeight = "bold"
//     peizhi.style.fontWeight = "normal"
// }
// function shanghupeizhi(){
//     document.getElementById('shanghuxiangqin').style.display = "none"
//     document.getElementById('shanghupeizhi').style.display = "block"
//     peizhi.style.fontWeight = "bold"
//     xiangqin.style.fontWeight = "normal"
// }
//额度
// function edu(a){
//     $.ajax({
//         url:initObj.url + '/api/user/updateUserAdministrators/' + id + '/' + userInformation.value + '/' + contacts.value + '/' + telephone.value + '/' + state.innerHTML,
//         type:'put',
//         contentType:'application/json;charset=utf-8',
//         datatype:'json',
//         beforeSend: function(request) {
//             request.setRequestHeader("token", form.token);
//         //    console.log(form.token)
//         },
//         success:function(res){
//             console.log(res)
//             alert(res.msg)
//         }
//     })
// }